package org.skyfree.ghyll.tcard.repository.internal;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.IPageSite;
import org.skyfree.ghyll.tcard.core.ITRepository;
import org.skyfree.ghyll.ui.property.AbstractPropertyPage;

public class RepositoryPage extends AbstractPropertyPage
{

	Text txtName;

    public RepositoryPage() {
        super();
    }
    
    

    @Override
	public void init(IPageSite pageSite) {
		// TODO Auto-generated method stub
		super.init(pageSite);
	}



	@Override
    public void createControl(Composite parent) {
        //Create your autual view UI here
        txtName = new Text(parent, SWT.BORDER);
    }

    @Override
    public Control getControl() {
        return txtName;
    }

    @Override
    public void setFocus() {

    }

    public void selectionChanged(IWorkbenchPart part, ISelection selection) 
    {
       /* String name = ; //Get information from selection
        txtName.setText(name);*/
    	StructuredSelection ss = (StructuredSelection)selection;
    	Object element = ss.getFirstElement();
    	if(element instanceof ITRepository)
    	{
    		txtName.setText(((ITRepository)element).getPath().getPath());
    	}
    	else txtName.setText("other select");
    	
    }
}
